<?php
use yii\helpers\Url;
use yii\web\View;
// use yii\Web\View;
use app\assets\NewCreativeAsset;
NewCreativeAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  [
    'label' => \Yii::t('creative', 'Creative'),
    'url' => ['creative-list']
  ],
  \Yii::t('creative', 'Edit Creative')
];
$jsMsgs = $this->context->loadJsMsgs([
  'creativeForm'
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('creative', 'Creative')?>
    <small><?=\Yii::t('creative', 'Edit Creative')?></small>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <i class="fa fa- edit"></i>
    <?=\Yii::t('creative', 'Edit Creative')?>
    <ul class="list-unstyled pull-right">
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-sm-8 col-sm-offset-2">
        <form class="form-horizontal" id="data-frm" method="POST" action="<?php echo Url::to(['creative/new-mobile-app-creative-handle']);?>">
          <input class="hidden" type="text" name="id" value="<?=$creative['id']?>">
          <input class="hidden" type="text" id="upload_type" value="1">
          <fieldset>
            <legend><?=\Yii::t('creative', 'Creative Info')?></legend>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="creative_name" >
                <em>*</em>
                <?=\Yii::t('creative', 'Creative Name')?>：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="creative_name" type="text" name="name" value="<?=$creative['name']?>" placeholder="<?=\Yii::t('creative', 'Creative Name')?>">
                <div class="help-block text-error" id="creative_name_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="advertiser_name" >
                <?=\Yii::t('creative', 'Advertiser')?>：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="advertiser_name" type="text" name="advertiser_name" value="<?=$creative['advertiser_name']?>" placeholder="<?=\Yii::t('creative', 'Advertiser')?>">
                <div class="help-block text-error" id="advertiser_name_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="creative_vocation_large" >
                <em>*</em>
                <?=\Yii::t('creative', 'Vocation')?>：
              </label>
              <div class="col-sm-3">
                <select class="form-control" id="creative_vocation_large" name="parent_category">
                </select>
              </div>
              <div class="col-md-3">
                <select class="form-control" id="creative_vocation_small" name="category">
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="landing_page_url">
                <em>*</em>
                <?=\Yii::t('creative', 'Target Url')?>：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="landing_page_url" type="text" name="landing_page" value="<?=$creative['landing_page']?>" placeholder="http(s)://">
                <div class="help-block text-error" id="landing_page_url_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="audit_target_url">
                <?=\Yii::t('creative', 'Audit Url')?>：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="audit_target_url" type="text" name="adomain" value="<?=$creative['adomain_full']?>" placeholder="http(s)://">
                <div class="help-block text-error" id="audit_target_url_err"></div>
              </div>
            </div>
            <!-- <div class="form-group">
              <label class="col-sm-2 control-label" for="landing_page_main_url">
                落地页主域名：
              </label>
              <div class="col-sm-10">
                <input class="form-control" id="landing_page_main_url" type="text" name="adomain" value="" placeholder="请填写一级域名或者二级域名。">
                <div class="help-block text-error" id="landing_page_main_url_err"></div>
                <p class="help-block">提示：如果网站URL是http://www.baidu.com，只需填写baidu.com；如果网站URL是http://www.sina.com.cn，只需填写sina.com.cn。</p>
              </div>
            </div> -->

                  <?php
        $shows = explode(';;;', $creative['show_monitor_url']);
        $title = \Yii::t('creative', 'Click to add show url');
        $showUrl = \Yii::t('creative', 'Show Url').':';
        foreach ($shows as $i => $show) {
          $btn = ' del-url-operate';
          $icon = 'fa-minus-circle';
          $label = '';
          $i == 0 && $btn = 'add-monitor-url';
          $i == 0 && $icon = 'fa-plus-circle';
          $i == 0 && $label = $showUrl;

          echo $showDiv = <<<FINE
            <div class="form-group impr-monitor-url monitor-url-form">
              <label class="col-sm-3 control-label" for="impr_monitor_url">
                $label
              </label>
              <div class="col-sm-7">
                <input class="form-control" type="text" data-role="show_url" name="show_monitor_url[]" value="$show" placeholder="http(s)://">
                <div class="help-block text-error monitor-url-error"></div>
              </div>
              <a class="btn btn-link $btn" title="$title" data-type="impr-monitor-url">
                <i class="fa $icon"></i>
              </a>
            </div>
FINE;
        }
      ?>
            <div class="form-group impr-monitor-url-new impr-monitor-url monitor-url-form hidden">
              <label class="col-sm-3 control-label" for="impr_monitor_url">
                <!-- <?=\Yii::t('creative', 'Show Url')?>： -->
              </label>
              <div class="col-sm-7">
                <input class="form-control" type="text" data-role="show_url" name="show_monitor_url[]" value="" placeholder="http(s)://">
                <div class="help-block text-error monitor-url-error"></div>
              </div>
              <a href="javascript:void(0);" class="btn btn-link del-url-operate" title="<?=\Yii::t('creative', 'Click to delete show url')?>" data-type="impr-monitor-url">
                <i class="fa fa-plus-circle fa-minus-circle"></i>
              </a>
            </div>
            <?php
        $clicks = explode(';;;', $creative['click_monitor_url']);
        $title = \Yii::t('creative', 'Click to add click url');
        $showUrl = \Yii::t('creative', 'Click Url').':';
        foreach ($clicks as $i => $click) {
          $btn = ' del-url-operate';
          $icon = 'fa-minus-circle';
          $label = '';
          $i == 0 && $btn = 'add-monitor-url';
          $i == 0 && $icon = 'fa-plus-circle';
          $i == 0 && $label = $showUrl;

          echo $showDiv = <<<FINE
            <div class="form-group click-monitor-url monitor-url-form">
              <label class="col-sm-3 control-label" for="click_monitor_url" >
                $label
              </label>
              <div class="col-sm-7">
                <input class="form-control" data-role="click_url" type="text" name="click_monitor_url[]" value="$click" placeholder="http(s)://">
                <div class="help-block text-error monitor-url-error"></div>
              </div>
              <a class="btn btn-link $btn" title="$title" data-type="click-monitor-url">
                <i class="fa $icon"></i>
              </a>
            </div>
FINE;
        }
      ?>
            <div class="form-group click-monitor-url-new click-monitor-url monitor-url-form hidden">
              <label class="col-sm-3 control-label" for="click_monitor_url" >
                <!-- <?=\Yii::t('creative', 'Click Url')?>： -->
              </label>
              <div class="col-sm-7">
                <input class="form-control" data-role="click_url" type="text" name="click_monitor_url[]" value="" placeholder="http(s)://">
                <div class="help-block text-error monitor-url-error"></div>
              </div>
              <a href="javascript:void(0);" class="btn btn-link del-url-operate" title="<?=\Yii::t('creative', 'Click to delete click url')?>" data-type="click-monitor-url">
                <i class="fa fa-plus-circle fa-minus-circle"></i>
              </a>
            </div>
            <div class="form-group">
              <label for="creative_type" class="col-sm-3 control-label">
                <em>*</em>
                <?=\Yii::t('creative', 'Creative Type')?>：
              </label>
              <div class="col-sm-7">
                <select class="form-control" id="creative_type" name="ad_type">
                  <!--<option value="0" <?php if($creative['ad_type']==0) echo "selected"; ?>><?=\Yii::t('creative', 'Banner')?></option>-->
                  <!--<option value="2" <?php if($creative['ad_type']==2) echo "selected"; ?>><?=\Yii::t('creative', 'Interstitial')?></option>-->
                  <option value="3" <?php if($creative['ad_type']==3) echo "selected"; ?>><?=\Yii::t('creative', 'Feeds')?></option>
                  <option value="1" <?php if($creative['ad_type']==1) echo "selected"; ?>><?=\Yii::t('creative', 'App Splash')?></option>
                </select>
              </div>
            </div> 
            <div id="feeds-sub-type-wrapper" class='<?php if($creative['ad_type']!=3){echo 'vam-hidden';}?>'>
              <div class="form-group">
                <label class="col-sm-3 control-label"></label>
                <div class="col-sm-7">
                  <!-- <label class="radio-inline">
                    <input type="radio" name="feeds_sub_type" value="0" <?php if($creative['subadtype']==0) echo 'checked';?>>默认
                  </label> -->
                  <label class="radio-inline">
                    <input type="radio" name="feeds_sub_type" value="1" <?php if($creative['subadtype']==1) echo 'checked';?>>图文
                  </label>
                  <label class="radio-inline">
                    <input type="radio" name="feeds_sub_type" value="2" <?php if($creative['subadtype']==2) echo 'checked';?>>大图
                  </label>
                  <label class="radio-inline">
                    <input type="radio" name="feeds_sub_type" value="3" <?php if($creative['subadtype']==3) echo 'checked';?>>三图
                  </label>
                </div>
              </div>
            </div>    
            <div class="form-group">
              <label for="creative_title" class="col-sm-3 control-label"  id="creative_title_label">
                <?=\Yii::t('creative', 'Title')?>：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="creative_title" name="title" data-err="creative_title_err" type="text" value="<?=$creative['title']?>">
                <div class="help-block text-error" id="creative_title_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label for="creative_description" class="col-sm-3 control-label">
                <?=\Yii::t('creative', 'Description')?>：
              </label>
              <div class="col-sm-7">
                 <input class="form-control" id="creative_description" data-err="creative_description_err" name="txt" type="text" value="<?=$creative['txt']?>">
                 <div class="help-block text-error" id="creative_description_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="alternative_creative_size">
                <?=\Yii::t('creative', 'Valid Size')?>：
              </label>
              <div class="col-sm-7">
                <p class="form-control-static" id="alternative_creative_size" name="alternative_creative_size"><?php
        $sizeList = [];
        foreach ($sizes as $k => $size) {
          $sizeList[] = $size['width'].'*'.$size['height'];
        }
        $sizeList = array_unique($sizeList);
        sort($sizeList);
        foreach ($sizeList as $k => $size) {
          if ($k < 1) {
            echo '<span class="size-item">'.$size.'</span>';
          } else if($k >= 1 && $k < 10) {
            echo '<span class="size-item">, '.$size.'</span>';
          } else {
            echo '<span class="size-item vam-hidden">, '.$size.'</span>';
          }
        }
        if (count($sizeList) > 10) {
          echo '<button title="'.Yii::t('creative', 'More').'" class="btn btn-link btn-xs view-more-size">'.Yii::t('creative', 'More').'</button>';
        }
        ?></p>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="alternative_creative_size">
                <?=\Yii::t('creative', 'Valid Material Type')?>：
              </label>
              <div class="col-sm-7">
                <p class="form-control-static" id="alternative_creative_size" name="alternative_creative_size">JPG,PNG,GIF</p>
              </div>
            </div>
            <div class="form-group" id="material_source">
              <label class="col-sm-3 control-label" for="alternative_creative_size">
                <?=\Yii::t('creative', 'Material Source')?>：
              </label>
              <div class="col-sm-7">
                <label class="radio-inline">
                  <input type="radio" name="material_source" value="0" <?if($creative['material_source'] == 0) echo "checked";?>><?=\Yii::t('creative', 'Upload Material')?>
                </label>
                <label class="radio-inline">
                  <input type="radio" name="material_source" value="1" <?if($creative['material_source'] == 1) echo "checked";?>><?=\Yii::t('creative', 'Custom Url')?>
                </label>
              </div>
            </div>



<!--             <div id="custom_material_url">
              <div class="custom-material-url">
                <div class="form-group">
                  <label for="custom-url" class="control-label col-sm-2 required">
                    <em>*</em>
                    <?=\Yii::t('creative', 'Material Url')?>：
                  </label>
                  <div class="col-sm-10">
                    <input type="text" id="" class="form-control custom-url" name="custom_url[]" value="" data-err="custom-url-err">
                    <div class="help-block text-error custom-url-err"></div>
                  </div>
                  <a class="btn btn-link add-material-url" title="<?=\Yii::t('creative', 'Click to add material url')?>" data-type="custom-material-url">
                    <i class="fa fa-plus-circle"></i>
                  </a>
                </div>
                <div class="form-group custom-adsize">
                  <label class="control-label col-md-2 required">
                    <em>*</em>
                    <?=\Yii::t('creative', 'Material Size')?>：
                  </label>
                  <label class="control-label col-md-1 required pr0">
                    <em>*</em>
                    <?=\Yii::t('creative', 'Width')?>：
                  </label>
                  <div class="col-md-3">
                    <input class="form-control adspace-width" type="text" value="" name="width[]" data-err="width-err">
                    <div class="help-block text-error width-err"></div>
                  </div>
                  <label class="control-label col-md-1 required pr0">
                    <em>*</em>
                    <?=\Yii::t('creative', 'Height')?>：
                  </label>
                  <div class="col-md-3">
                    <input class="form-control adspace-height" type="text" value="" name="height[]" data-err="height-err">
                    <div class="help-block text-error height-err"></div>
                  </div>
                </div>
                <div class="form-group">
                  <label for="material-type" class="col-md-2 control-label required">
                    <em>*</em>
                    <?=\Yii::t('creative', 'Material Type')?>：
                  </label>
                  <div class="col-md-10">
                    <select name="material_type[]" id="" class="form-control">
                      <option value="JPG">JPG</option>
                      <option value="PNG">PNG</option>
                    </select>
                  </div>
                </div>
              </div>
            </div> -->
            <div id="custom_material_url">
            <?php
              $urlMsg = \Yii::t('creative', 'Material Url');
              $sizeMsg = \Yii::t('creative', 'Material Size');
              $widthMsg = \Yii::t('creative', 'Width');
              $heightMsg = \Yii::t('creative', 'Height');
              $typeMsg = \Yii::t('creative', 'Material Type');
              $out = '';
              if ($creative['material_source'] == 1 && $creative['file_url']) {
                $fileUrls = explode(',', $creative['file_url']);
                // $widths = explode(',', $creative['width']);
                // $heights = explode(',', $creative['height']);
                $sizeLists = explode(',',$creative['size_list']);
                $exts = explode(',', $creative['ext']);
                foreach ($fileUrls as $i => $fileUrl) {
                  // $width = $widths[$i];
                  // $height = $heights[$i];
                  $sizeList = explode('*', $sizeLists[$i]);
                  $width = $sizeList[0];
                  $height = $sizeList[1];

                  $ext = $exts[$i];
                  $jpgSelect = '';
                  $pngSelect = '';
                  $gifSelect = '';
                  if(strtoupper($ext) == 'JPG') $jpgSelect = "selected";
                  if(strtoupper($ext) == 'PNG') $pngSelect = "selected";
                  if(strtoupper($ext) == 'GIF') $gifSelect = "selected";

                  $btn = 'del-operate';
                  $icon = 'fa-minus-circle';
                  $urlTitleMsg = \Yii::t('creative', 'Click to delete material url');
                  $i==0 && $btn = 'add-material-url';
                  $i==0 && $icon = 'fa-plus-circle';
                  $i==0 && $urlTitleMsg = \Yii::t('creative', 'Click to add material url');

                  $out .= <<<FINE
                      <div class="custom-material-url">
                        <div class="form-group">
                          <label for="custom-url" class="control-label col-sm-3 required">
                            <em>*</em>
                            ${urlMsg}：
                          </label>
                          <div class="col-sm-7">
                            <input type="text" id="" class="form-control custom-url" name="custom_url[]" value="$fileUrl" data-err="custom-url-err">
                            <div class="help-block text-error custom-url-err"></div>
                          </div>
                          <a class="btn btn-link $btn" title="$urlTitleMsg" data-type="custom-material-url">
                            <i class="fa $icon"></i>
                          </a>
                        </div>
                        <div class="form-group custom-adsize">
                          <label class="control-label col-md-3 required">
                            <em>*</em>
                            ${sizeMsg}：
                          </label>
                          <label class="control-label required col-md-1 pr0">
                            <em>*</em>
                            ${widthMsg}：
                          </label>
                          <div class="col-md-2">
                            <input class="form-control adspace-width" type="text" value="$width" name="width[]" data-err="width-err">
                            <div class="help-block text-error width-err"></div>
                          </div>
                          <label class="control-label required col-md-1 pr0">
                            <em>*</em>
                            ${heightMsg}：
                          </label>
                          <div class="col-md-2">
                            <input class="form-control adspace-height" type="text" value="$height" name="height[]" data-err="height-err">
                            <div class="help-block text-error height-err"></div>
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="material-type" class="col-md-3 control-label required">
                            <em>*</em>
                            ${typeMsg}：
                          </label>
                          <div class="col-md-7">
                            <select name="material_type[]" id="" class="form-control">
                              <option value="JPG" $jpgSelect>JPG</option>
                              <option value="PNG" $pngSelect>PNG</option>
                              <option value="GIF" $gifSelect>GIF</option>
                            </select>
                          </div>
                        </div>
                      </div>
FINE;
                }
              } else {
                  $btn = 'add-material-url';
                  $icon = 'fa-plus-circle';
                  $urlTitleMsg = \Yii::t('creative', 'Click to add material url');
                  $out = <<<FINE
                      <div class="custom-material-url">
                        <div class="form-group">
                          <label for="custom-url" class="control-label col-sm-3 required">
                            <em>*</em>
                            ${urlMsg}：
                          </label>
                          <div class="col-sm-7">
                            <input type="text" id="" class="form-control custom-url" name="custom_url[]" value="" data-err="custom-url-err">
                            <div class="help-block text-error custom-url-err"></div>
                          </div>
                          <a class="btn btn-link $btn" title="$urlTitleMsg" data-type="custom-material-url">
                            <i class="fa $icon"></i>
                          </a>
                        </div>
                        <div class="form-group custom-adsize">
                          <label class="control-label col-md-3 required">
                            <em>*</em>
                            ${sizeMsg}：
                          </label>
                          <label class="control-label col-md-1 pr0 required">
                            <em>*</em>
                            ${widthMsg}：
                          </label>
                          <div class="col-md-2">
                            <input class="form-control adspace-width" type="text" value="" name="width[]" data-err="width-err">
                            <div class="help-block text-error width-err"></div>
                          </div>
                          <label class="control-label col-md-1 pr0 required">
                            <em>*</em>
                            ${heightMsg}：
                          </label>
                          <div class="col-md-2">
                            <input class="form-control adspace-height" type="text" value="" name="height[]" data-err="height-err">
                            <div class="help-block text-error height-err"></div>
                          </div>
                        </div>
                        <div class="form-group">
                          <label for="material-type" class="col-md-3 control-label required">
                            <em>*</em>
                            ${typeMsg}：
                          </label>
                          <div class="col-md-7">
                            <select name="material_type[]" id="" class="form-control">
                              <option value="JPG">JPG</option>
                              <option value="PNG">PNG</option>
                              <option value="GIF">GIF</option>
                            </select>
                          </div>
                        </div>
                      </div>
FINE;
              }
              echo $out;
            ?>
            </div>
            <div id="local_upload_material">
			  <div class="form-group" id="material_hero_choice">
				  <label class="col-sm-3 control-label" for="alternative_creative_hero_choice">
					<?=\Yii::t('creative', 'For Hero App')?>：
				  </label>
				  <div class="col-sm-7">
					<label class="radio-inline">
					  <input type="radio" name="hero_app" value="0" <?php if($creative['hero_app'] != 1 ) echo  "checked"; ?>>否
					</label>
					<label class="radio-inline">
					  <input type="radio" name="hero_app" value="1" <?php if($creative['hero_app'] == 1 ) echo  "checked"; ?>>是
					</label>
				  </div>
			  </div>
			  <div class="form-group" id="material_protocal">
				  <label class="col-sm-3 control-label" for="alternative_creative_size">
					<?=\Yii::t('creative', 'Material Protocal')?>：
				  </label>
				  <div class="col-sm-7">
					<label class="radio-inline">
					  <input type="radio" name="protocal" value="1" <?php if($creative['protocal'] != 2 ) echo  "checked"; ?>>HTTP
					</label>
					<label class="radio-inline">
					  <input type="radio" name="protocal" value="2" <?php if($creative['protocal'] == 2 ) echo  "checked"; ?>>HTTPS
					</label>
				  </div>
			  </div>
              <div class="form-group">
                <label class="col-sm-3 control-label required" id="upload_material_label" for="upload_material">
                  <?=\Yii::t('creative', 'Upload Material')?>：
                </label>
                <div class="col-sm-2 col-sm-offset-7">
                  <button class="btn btn-info" id="upload-material" type="button">
                    <i class="fa fa-upload"></i>
                    <?=\Yii::t('creative', 'Upload')?>
                  </button>
                </div>
                <div class="col-sm-12 mt10 text-center">
                  <div class="creative-preview-wrap">
                  <?php
                    if ($creative['material_source'] == 0) {
                      $delete = \Yii::t('creative', 'Delete');
                      foreach ($materials as $material) {
                        $pic = $material['url'];
                        $id = $material['id'];
                        $preview = '';
                        if (in_array($material['ext'], ['jpg', 'gif', 'png'])) {
                          $preview =<<<FINE
                          <div class="creative-preview">
                            <img class="img-thumbnail creative_material_preview" src="$pic" style="max-width: 310px; max-height: 260px;">
                            <input name="upload_material[]" type="hidden" value="$id">
                            <button class="btn btn-link btn-s btn-sm preview-close">$delete</button>
                          </div>
FINE;
                        }
                        echo $preview;
                      }
                    }
                  ?>
                  </div>
                  <?php
                    $out = '';
  		              $unupload = \Yii::t('creative', 'Not upload');
                    if($creative['material_source'] == 0 && $materials) {
                      $out = '<img class="img-thumbnail creative_material_default hidden" id="creative_material_default" data-src="holder.js/310x260/text:'.$unupload.'" alt="'.$unupload.'">';
                    } else {
                      $out = '<img class="img-thumbnail creative_material_default" id="creative_material_default" data-src="holder.js/310x260/text:'.$unupload.'" alt="'.$unupload.'">';
                    }
                    echo $out;
                  ?>
                  <input id="upload_material" data-err="upload_material_err" type="hidden" value="">
                  <div class="help-block text-error" id="upload_material_err"></div>
                </div>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <div class="form-group">
              <div class="col-sm-offset-3 col-sm-7">
                <div class="btn-form-group pull-right">
                  <input class="operate-type" type="hidden" name="operate_type" value="save">
                  <button type="submit" class="btn btn-primary" data-loading-text="<i class='fa fa-spinner fa-spin'></i> <?=\Yii::t('common', 'Saving')?>..."><?=\Yii::t('common', 'Save')?></button>
                  <a href="<?php echo Url::to(['creative/creative-list']); ?>" class="btn btn-default"><?=\Yii::t('common', 'Back')?></a>
                </div>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="upload-material-modal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title"><?=\Yii::t('creative', 'Upload Material')?></h4>
      </div>
      <div class="modal-body">
        <div class="portlet-content">
          <span class="btn btn-success btn-sm fileinput-button">
            <i class="fa fa-plus"></i>
            <span><?=\Yii::t('creative', 'File')?></span>
            <input id="creative-id" type="hidden" name="creative_id" value="${id}" >
            <!-- The file input field used as target for the file upload widget -->
            <input type="file" multiple="" name="files[]" id="fileupload">
          </span>
          <br>
          <br>
          <!-- The global progress bar -->
          <div class="progress" id="progress">
              <div aria-valuemax="100" aria-valuemin="0" class="progress-bar progress-bar-success progress-bar-striped">0%</div>
          </div>
          <!-- The container for the uploaded files -->
          <div class="files" id="files">
            <table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th>ID</th>
                  <th><?=\Yii::t('creative', 'File Name')?></th>
                  <th><?=\Yii::t('creative', 'File Size')?>(KB)</th>
                  <th><?=\Yii::t('creative', 'Upload Time')?></th>
                  <th><?=\Yii::t('creative', 'Info')?></th>
                  <th><?=\Yii::t('creative', 'Uploader')?></th>
                </tr>
              </thead>
              <tbody></tbody>
              </table>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><?=\Yii::t('common', 'Close')?></button>
        <button type="button" class="btn btn-primary" id="upload-confirm-operate" data-material-id=""><?=\Yii::t('common', 'Sure')?></button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="custom-material-url new-custom-url hidden">
  <div class="form-group">
    <label for="custom-url" class="control-label col-sm-3">
      <?=\Yii::t('creative', 'Material Url')?>：
    </label>
    <div class="col-sm-7">
      <input type="text" id="" class="form-control custom-url" name="custom_url[]" value="" data-err="custom-url-err">
      <div class="help-block text-error custom-url-err"></div>
    </div>
    <a class="btn btn-link del-operate" title="<?=\Yii::t('creative', 'Click to delete material url')?>" data-type="custom-material-url">
      <i class="fa fa-plus-circle fa-minus-circle"></i>
    </a>
  </div>
  <div class="form-group custom-adsize">
    <label class="control-label col-md-3">
      <?=\Yii::t('creative', 'Material Size')?>：
    </label>
    <label class="control-label col-md-1 pr0">
      <?=\Yii::t('creative', 'Width')?>：
    </label>
    <div class="col-md-2">
      <input class="form-control adspace-width" type="text" value="" name="width[]" data-err="width-err">
      <div class="help-block text-error width-err "></div>
    </div>
    <label class="control-label col-md-1 pr0">
      <?=\Yii::t('creative', 'Height')?>：
    </label>
    <div class="col-md-2">
      <input class="form-control adspace-height" type="text" value="" name="height[]" data-err="height-err">
      <div class="help-block text-error height-err"></div>
    </div>
  </div>
  <div class="form-group">
    <label for="material-type" class="col-md-3 control-label">
      <?=\Yii::t('creative', 'Material Type')?>：
    </label>
    <div class="col-md-7">
      <select name="material_type[]" id="" class="form-control">
        <option value="JPG">JPG</option>
        <option value="PNG">PNG</option>
        <option value="GIF">GIF</option>
      </select>
    </div>
  </div>
</div>
<?php
  // $uploadMaterialUrl = Url::to(['creative/upload-video']);
  $uploadMaterialUrl =  Url::to(['creative/upload-mobile-app-pic']);
  $videoPluginUrl = Yii::getAlias('@web/').Yii::$app->params['envDir'].'/js/vendor/flowplayer/flowplayer.swf';
  $creativeVocation = $categories;
  //$creativeVocation = '{"汽车":["车讯行情","车辆养护","配件改装","其它"],"新闻":["军事","时政要闻","产经","科技","其它"],"财经":["股票","基金","理财","房产","保险","收藏","其它"],"数码":["电脑","手机","数码设备","软件","APP","其它"],"医疗":["健康养生","疾病治疗","整形美容","两性","其它"],"娱乐影音":["影视","音乐","图书","图片","星座","明星","游戏","宠物","休闲活动","其它"],"社交与网络服务":["婚恋交友","SNS","论坛","网络服务"],"教育":["幼教","应试","考研","培训","MBA","出国","自考","其它"],"家居家电":["家电","家具","装修","装饰","日常用品"],"体育":["足球","篮球","网球","户外","健身","器材","其它"],"旅行":["酒店和住宿","旅行社和服务","票务服务"],"女性":["时尚","美容","母婴"],"职业":["简历","招聘信息","其它"],"食品饮料":["美食","零食","饮料","烟酒","保健食品","其它"],"服饰鞋包":["服装","鞋靴","配饰","珠宝首饰","箱包","钟表","奢侈品","眼镜"],"工农业":["电子电工","机械设备","农林牧渔","化工及材料"],"生活和商务服务":["生活服务","商务服务"]}';
  $this->registerJs("VAM.setVar('UPLOAD_MATERIAL_URL','$uploadMaterialUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('VIDEO_PLUGIN_URL','$videoPluginUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('CREATIVE_VOCATION','$creativeVocation')", View::POS_HEAD);

  $parentCategory = array_shift($category);
  $childCategory = array_shift($category);
  $this->registerJs("VAM.setVar('parent_category','$parentCategory')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('child_category','$childCategory')", View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/creative/newAppCreative.js"]);
  });
</script>
